package com.isoftstone.common.service.impl;


import com.isoftstone.common.Page;
import com.isoftstone.common.dao.SysRoleMapper;
import com.isoftstone.common.entity.SysRole;
import com.isoftstone.common.service.ISysRoleService;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;


@Service
public class SysRoleService implements ISysRoleService {

    @Autowired
    SysRoleMapper sysRoleMapper;


    public SysRole getRoleById(String roleId) throws Exception {
        return sysRoleMapper.getRoleById(roleId);
    }

    public SysRole getRoleByCode(String roleCode) throws Exception {
        return sysRoleMapper.getRoleByCode(roleCode);
    }

    public List<SysRole> getRolelistPage(Page page) throws Exception {
        return sysRoleMapper.getRolelistPage(page);
    }

    @Transactional
    public void saveRole(SysRole role) throws Exception {
        sysRoleMapper.saveRole(role);
    }
    @Transactional
    public void updateRole(SysRole role) throws Exception {
        sysRoleMapper.updateRole(role);
    }

    @Transactional
    public void deleteRole(String roleId) throws Exception {
        sysRoleMapper.deleteRole(roleId);
    }

    @Override
    public List<SysRole> getSysRole(@Param("comCode") String comCode) throws Exception {
        return sysRoleMapper.getSysRole(comCode);
    }

    @Override
    public List<SysRole> getCompanyRoles(String empCode,String comCode) throws Exception {
        return sysRoleMapper.getCompanyRoles(empCode, comCode);
    }

    @Override
    public SysRole getRoleByCorpIdAndUserId(String corpId, String userId) throws Exception {
        return sysRoleMapper.getRoleByCorpIdAndUserId(corpId,userId);
    }

    @Override
    public void updateRoleByidAndcorpId(int roleId, String corpId) throws Exception {
        sysRoleMapper.updateRoleByidAndcorpId(roleId,corpId);
    }

    @Override
    public String getParentRoleIdByRoleid(String roleId) throws Exception {
        return sysRoleMapper.getParentRoleIdByRoleid(roleId);
    }

    @Override
    public List<SysRole> getBankRolePage(Page page) {
        return sysRoleMapper.getBankRolelistPage(page);
    }

    @Override
    public List<SysRole> getRolelist(String corpId) throws Exception {
        return sysRoleMapper.getRolelist(corpId);
    }

    @Override
    public String getRoleNameByRoleNameandCorpId(String roleName, String corpId) throws Exception {
        return sysRoleMapper.getRoleNameByRoleNameandCorpId(roleName,corpId);
    }

    @Override
    public List<SysRole> getBankRoleTree() {
        return sysRoleMapper.getBankRoleTree();
    }

    public List<SysRole> getRole() throws Exception {
		return sysRoleMapper.getRole();
	}
}
